Is a privately held financial, software, data, and media company headquartered in Midtown Manhattan, New York City. It was co-founded by Michael Bloomberg in 1981, with Thomas Secunda, Duncan MacMillan, Charles Zegar,[9] and a 12% ownership investment by Bank of America through their brokerage subsidiary Merrill Lynch.[10]
is an American basic cable business news channel and website. It provides business news programming on weekdays from 5:00 a.m. to 7:00 p.m., Eastern Time, while broadcasting talk shows, investigative reports, documentaries, infomercials, reality shows, and other programs at all other times.
It provides financial news, data and commentary including stock quotes, press releases, financial reports, and original content.
is a British weekly newspaper printed in magazine format and published digitally. It focuses on current affairs, international business, politics, technology, and culture
At Kitco News, we deliver insightful, reliable, comprehensive investment news and analysis. We provide a range of opinions and perspectives allowing our viewers to make informed decisions. Our journalists interview experts, analysts, traders, authors and industry leaders across various sectors, including precious metals, cryptocurrencies, commodities, finance, geopolitics and technology.
# lets import libraries
from googleapiclient.discovery import build
import pandas as pd
import seaborn as sns
api_key = 'AIzaSyB24Kop04L1GlTgRCm1XtQ4KB2a4gaBOwA'
Bloomberg_channel_id = ['UCIALMKvObZNtJ6AmdCLP7Lg' # Bloomberg
]
youtube = build('youtube','v3',developerKey = api_key)
from googleapiclient.errors import HttpError
def get_channel_stats(youtube, Bloomberg_channel_id):
all_data = []
try:
request = youtube.channels().list(
part='snippet,contentDetails,statistics',
id=','.join(Bloomberg_channel_id)
)
response = request.execute()
for item in response.get('items', []):
snippet = item.get('snippet', {})
statistics = item.get('statistics', {})
data = {
'Channel_name': snippet.get('title', ''),
'Subscribers': statistics.get('subscriberCount', ''),
'Views': statistics.get('viewCount', ''),
'Total_videos': statistics.get('videoCount', '')
}
all_data.append(data)
except HttpError as e:
print(f"HTTP error occurred: {e}")
print(f"Request URL: {e.resp.request.url}")
print(f"Request body: {e.resp.request.body}")
return all_data
get_channel_stats(youtube,Bloomberg_channel_id)
[{'Channel_name': 'Bloomberg Television', 'Subscribers': '1790000', 'Views': '778358870', 'Total_videos': '61566'}]
channel_statistics = get_channel_stats(youtube, Bloomberg_channel_id)
Bloomberg_channel_data =pd.DataFrame(channel_statistics)
Bloomberg_channel_data
Channel_name | Subscribers | Views | Total_videos | |
---|---|---|---|---|
0 | Bloomberg Television | 1790000 | 778358870 | 61566 |
api_key = 'AIzaSyB24Kop04L1GlTgRCm1XtQ4KB2a4gaBOwA'
CNBC_channel_id = ['UCvJJ_dzjViJCoLf5uKUTwoA' # CNBC
]
youtube = build('youtube','v3',developerKey = api_key)
from googleapiclient.errors import HttpError
def get_channel_stats(youtube, CNBC_channel_id):
all_data = []
try:
request = youtube.channels().list(
part='snippet,contentDetails,statistics',
id=','.join(CNBC_channel_id)
)
response = request.execute()
for item in response.get('items', []):
snippet = item.get('snippet', {})
statistics = item.get('statistics', {})
data = {
'Channel_name': snippet.get('title', ''),
'Subscribers': statistics.get('subscriberCount', ''),
'Views': statistics.get('viewCount', ''),
'Total_videos': statistics.get('videoCount', '')
}
all_data.append(data)
except HttpError as e:
print(f"HTTP error occurred: {e}")
print(f"Request URL: {e.resp.request.url}")
print(f"Request body: {e.resp.request.body}")
return all_data
get_channel_stats(youtube, CNBC_channel_id)
[{'Channel_name': 'CNBC', 'Subscribers': '3300000', 'Views': '1490322437', 'Total_videos': '15177'}]
channel_statistics = get_channel_stats(youtube, CNBC_channel_id)
CNBC_channel_data =pd.DataFrame(channel_statistics)
CNBC_channel_data
Channel_name | Subscribers | Views | Total_videos | |
---|---|---|---|---|
0 | CNBC | 3300000 | 1490322437 | 15177 |
api_key = 'AIzaSyB24Kop04L1GlTgRCm1XtQ4KB2a4gaBOwA'
Yahoo_Finance_id = ['UCEAZeUIeJs0IjQiqTCdVSIg' # Yahoo Finance
]
youtube = build('youtube','v3',developerKey = api_key)
from googleapiclient.errors import HttpError
def get_channel_stats(youtube, Yahoo_Finance_id):
all_data = []
try:
request = youtube.channels().list(
part='snippet,contentDetails,statistics',
id=','.join(Yahoo_Finance_id)
)
response = request.execute()
for item in response.get('items', []):
snippet = item.get('snippet', {})
statistics = item.get('statistics', {})
data = {
'Channel_name': snippet.get('title', ''),
'Subscribers': statistics.get('subscriberCount', ''),
'Views': statistics.get('viewCount', ''),
'Total_videos': statistics.get('videoCount', '')
}
all_data.append(data)
except HttpError as e:
print(f"HTTP error occurred: {e}")
print(f"Request URL: {e.resp.request.url}")
print(f"Request body: {e.resp.request.body}")
return all_data
get_channel_stats(youtube, Yahoo_Finance_id)
[{'Channel_name': 'Yahoo Finance', 'Subscribers': '1100000', 'Views': '405205248', 'Total_videos': '46980'}]
channel_statistics = get_channel_stats(youtube, Yahoo_Finance_id)
Yahoo_channel_data =pd.DataFrame(channel_statistics)
Yahoo_channel_data
Channel_name | Subscribers | Views | Total_videos | |
---|---|---|---|---|
0 | Yahoo Finance | 1100000 | 405205248 | 46980 |
api_key = 'AIzaSyB24Kop04L1GlTgRCm1XtQ4KB2a4gaBOwA'
The_Economist_channel_id = ['UC0p5jTq6Xx_DosDFxVXnWaQ' # The Economist
]
youtube = build('youtube','v3',developerKey = api_key)
from googleapiclient.errors import HttpError
def get_channel_stats(youtube, The_Economist_channel_id):
all_data = []
try:
request = youtube.channels().list(
part='snippet,contentDetails,statistics',
id=','.join(The_Economist_channel_id)
)
response = request.execute()
for item in response.get('items', []):
snippet = item.get('snippet', {})
statistics = item.get('statistics', {})
data = {
'Channel_name': snippet.get('title', ''),
'Subscribers': statistics.get('subscriberCount', ''),
'Views': statistics.get('viewCount', ''),
'Total_videos': statistics.get('videoCount', '')
}
all_data.append(data)
except HttpError as e:
print(f"HTTP error occurred: {e}")
print(f"Request URL: {e.resp.request.url}")
print(f"Request body: {e.resp.request.body}")
return all_data
get_channel_stats(youtube, The_Economist_channel_id)
[{'Channel_name': 'The Economist', 'Subscribers': '3260000', 'Views': '328815390', 'Total_videos': '600'}]
channel_statistics = get_channel_stats(youtube, The_Economist_channel_id)
The_Economist_channel_data =pd.DataFrame(channel_statistics)
The_Economist_channel_data
Channel_name | Subscribers | Views | Total_videos | |
---|---|---|---|---|
0 | The Economist | 3260000 | 328815390 | 600 |
api_key = 'AIzaSyB24Kop04L1GlTgRCm1XtQ4KB2a4gaBOwA'
Kitco_News_channel_id = ['UC9ijza42jVR3T6b8bColgvg' # Kitco News
]
youtube = build('youtube','v3',developerKey = api_key)
from googleapiclient.errors import HttpError
def get_channel_stats(youtube, Kitco_News_channel_id):
all_data = []
try:
request = youtube.channels().list(
part='snippet,contentDetails,statistics',
id=','.join(Kitco_News_channel_id)
)
response = request.execute()
for item in response.get('items', []):
snippet = item.get('snippet', {})
statistics = item.get('statistics', {})
data = {
'Channel_name': snippet.get('title', ''),
'Subscribers': statistics.get('subscriberCount', ''),
'Views': statistics.get('viewCount', ''),
'Total_videos': statistics.get('videoCount', '')
}
all_data.append(data)
except HttpError as e:
print(f"HTTP error occurred: {e}")
print(f"Request URL: {e.resp.request.url}")
print(f"Request body: {e.resp.request.body}")
return all_data
get_channel_stats(youtube, Kitco_News_channel_id )
[{'Channel_name': 'Kitco NEWS', 'Subscribers': '613000', 'Views': '144857028', 'Total_videos': '4247'}]
channel_statistics = get_channel_stats(youtube,Kitco_News_channel_id )
Kitco_News_channel_data =pd.DataFrame(channel_statistics)
Kitco_News_channel_data
Channel_name | Subscribers | Views | Total_videos | |
---|---|---|---|---|
0 | The Economist | 3260000 | 328815390 | 600 |
# Combine DataFrames using concat
combined_Financial_News_channels_df = pd.concat([
Bloomberg_channel_data ,
CNBC_channel_data,
Yahoo_channel_data ,
The_Economist_channel_data ,
Kitco_News_channel_data,
], ignore_index=True)
# Display the result
print(combined_Financial_News_channels_df)
Channel_name Subscribers Views Total_videos 0 Bloomberg Television 1790000 778358870 61566 1 CNBC 3300000 1490322437 15177 2 Yahoo Finance 1100000 405205248 46980 3 The Economist 3260000 328815390 600 4 The Economist 3260000 328815390 600
# lets have a look at the datatypes
combined_Financial_News_channels_df.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 5 entries, 0 to 4 Data columns (total 4 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Channel_name 5 non-null object 1 Subscribers 5 non-null int64 2 Views 5 non-null int64 3 Total_videos 5 non-null int64 dtypes: int64(3), object(1) memory usage: 292.0+ bytes
# lets change the datatypes to perform visualisations
combined_Financial_News_channels_df['Subscribers'] = pd.to_numeric(combined_Financial_News_channels_df['Subscribers'])
combined_Financial_News_channels_df['Views'] = pd.to_numeric(combined_Financial_News_channels_df['Views'])
combined_Financial_News_channels_df['Total_videos'] = pd.to_numeric(combined_Financial_News_channels_df['Total_videos'])
# letsconirm if the datatypes has changed
combined_Financial_News_channels_df.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 5 entries, 0 to 4 Data columns (total 4 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Channel_name 5 non-null object 1 Subscribers 5 non-null int64 2 Views 5 non-null int64 3 Total_videos 5 non-null int64 dtypes: int64(3), object(1) memory usage: 292.0+ bytes
combined_Financial_News_channels_df
Channel_name | Subscribers | Views | Total_videos | |
---|---|---|---|---|
0 | Bloomberg Television | 1790000 | 778358870 | 61566 |
1 | CNBC | 3300000 | 1490322437 | 15177 |
2 | Yahoo Finance | 1100000 | 405205248 | 46980 |
3 | The Economist | 3260000 | 328815390 | 600 |
4 | The Economist | 3260000 | 328815390 | 600 |
import matplotlib.pyplot as plt
# Sort the DataFrame by 'Subscribers' in descending order
combined_Financial_News_channels_df_subscribers_sorted =combined_Financial_News_channels_df.sort_values(by='Subscribers', ascending=False)
# Plotting Subscribers in descending order
fig, axes = plt.subplots(nrows=3, ncols=1, figsize=(10, 15))
axes[0].bar(combined_Financial_News_channels_df_subscribers_sorted['Channel_name'], combined_Financial_News_channels_df_subscribers_sorted['Subscribers'], color='blue')
axes[0].set_title('Subscribers')
# Sort the DataFrame by 'Views' in descending order
combined_Financial_News_channels_df_views_sorted = combined_Financial_News_channels_df.sort_values(by='Views', ascending=False)
# Plotting Views in descending order
axes[1].bar(combined_Financial_News_channels_df_views_sorted['Channel_name'], combined_Financial_News_channels_df_views_sorted['Views'], color='green')
axes[1].set_title('Views')
# Sort the DataFrame by 'Total_videos' in descending order
combined_Financial_News_channels_df_total_videos_sorted = combined_Financial_News_channels_df.sort_values(by='Total_videos', ascending=False)
# Plotting Total Videos in descending order
axes[2].bar(combined_Financial_News_channels_df_total_videos_sorted['Channel_name'], combined_Financial_News_channels_df_total_videos_sorted['Total_videos'], color='orange')
axes[2].set_title('Total Videos')
# Adjust layout for better visibility
plt.tight_layout()
# Show the plot
plt.show()